const setting = require('./setting');
const mongoose = require('mongoose');

mongoose.connect(setting.connectString, { useNewUrlParser: true }).then(
    () => {
        /** ready to use. The `mongoose.connect()` promise resolves to undefined. */
        console.log('mongo连接成功');
        process.send('ready');
        console.log('pm2 ready');
    },
    err => {
        /** handle initial connection error */
        console.log('mongo连接失败：', err);
    }
);

module.exports = {
    mongoose: mongoose
};
